package com.ecmp.demo.controller;

import com.ecmp.annotation.IgnoreCheckAuth;
import com.ecmp.config.util.ApiClient;
import com.ecmp.core.controller.BaseEntityController;
import com.ecmp.demo.api.ICommunityService;
import com.ecmp.demo.entity.Community;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2017/8/10.
 */
@Controller
@IgnoreCheckAuth
@RequestMapping(value = "/community")
public class CommunityController extends BaseEntityController<Community> {

    /**
     * @return 页面
     */
//    @RequestMapping(value = "show", method = RequestMethod.GET)
//    public String show() {
//        return "CommunityView";
//    }
    @Override
    protected String getReturnView(HttpServletRequest request) {
        return "CommunityView";
    }

    @Override
    protected Object getBaseService() {
        return ApiClient.createProxy(ICommunityService.class);
    }
    /**
     * @return 社团清单
     */
/*    @ResponseBody
    @RequestMapping(value = "listAll")
    public List<Community> listAll() {
        ICommunityService proxy = ApiClient.createProxy(ICommunityService.class);
        return proxy.findAll();
    }*/

    /**
     * 保存一个社团
     *
     * @param community 社团实体
     * @return 操作结果
     */
/*    @ResponseBody
    @RequestMapping(value = "save")
    public String save(Community community) {
        ICommunityService proxy = ApiClient.createProxy(ICommunityService.class);
        OperateResultWithData<Community> result = proxy.save(community);
        Boolean success = result.successful();
        String mes = result.getMessage();
        Community data = result.getData();
        OperateStatus operateStatus = new OperateStatus(success, mes, data);
        return JsonUtil.serialize(operateStatus);
    }*/

 /*   @ResponseBody
    @RequestMapping(value = "delete")
    public String delete(String id) {
        ICommunityService proxy = ApiClient.createProxy(ICommunityService.class);
        OperateResult result = proxy.delete(id);
        OperateStatus operateStatus = new OperateStatus(result.successful(), result.getMessage());
        return JsonUtil.serialize(operateStatus);
    }*/

    /**
     * 获取当前用户有权限的社团
     *
     * @return 社团清单
     */
/*    @ResponseBody
    @RequestMapping(value = "listAllUserAuthorizedCommunity")
    public List<Community> listAllUserAuthorizedCorporations() {
        ICommunityService proxy = ApiClient.createProxy(ICommunityService.class);
        //如果是树形结构则调用树形结构接口的getUserAuthorizedTreeEntities方法
        return proxy.getUserAuthorizedEntities(null);
    }*/
}
